Skip to main content

equals

Type

operator

Summary

Compares two values and evaluates to true if they are equal, false if they are not equal.

Syntax

<value1> = value2

Description

Use the = (equality) operator to find out whether two numeric expressions yield the same number or whether two strings are equivalent.

note

A string in the form "xEy", where x is a number and y is an integer will be treated as a number in scientific notation. This means that such a string is evaluated as x * 10^y. For example:

    put \"3e2\" = \"300\" -- returns true

When comparing strings, the = operator compares the two values character by character. If the caseSensitive property is true, the comparison between two strings treats uppercase letters as coming before lowercase letters. If the caseSensitive property is false, the comparison is not case-sensitive, so "a" = "A".

When comparing arrays, the = operator first checks if the number of elements in each array is the same, if not the two arrays are different. If the arrays have the same number of elements, they are equal if each element is equal. Specifically this means:

array1 = array2 if (and only if):

  • the number of elements of array1 = the number of elements of array2
    and 
- for each element e in array1, array1[e] = array2[e].
note

If an array is compared with a string, the array will first be converted into the empty string, thus any array is always equal to the empty string, and not equal to any other string.

note

As of LiveCode 6.0 onwards expressions such as 'tArray is empty' will return true is and only if tArray contains the empty string. For example

    put empty into tArray
answer tArray is empty -- true

put 100 into tArray["foo"]

    answer tArray is empty -- false (prior to 6.0 this would be true)

Parameters

NameTypeDescription

value1

The operands value1 and value2 can be numbers, literal strings of characters (delimited with double quotes), or any sources of value, including arrays.

Examples

1 = 0 -- evaluates to false
17 + 9 = 26 -- evaluates to true
"ABC" = "abc" -- true if and only if caseSensitive is false

glossary: property, operator, case-sensitive, scientific notation, value, string, expression

keyword: character, numeric

operator: less-than-or-greater-than, contains

property: caseSensitive

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?